extends CharacterBody2D

#region 参数配置
@onready var animationComponent := $PlayerAnimation
@onready var movementComponent := $PlayerMovement
@onready var hurtComponent := $PlayerHurt

func _ready():
	Global.player = self

#region 物理处理
func _physics_process(delta):
	# 获取当前平台速度
	movementComponent.handle_movement(delta)
	move_and_slide()
	# handle_floor(platform_velocity)
	hurtComponent.handle_hurt()
	animationComponent.update_animation_state()
	
func handle_floor(platform_velocity):
	# 更新平台关联（防止穿模的关键）
	if is_on_floor() and platform_velocity != Vector2.ZERO:
		var collision = get_last_motion()
		if collision:
			position += collision.get_remainder()
